/**
 * @param {string} s
 * @return {string}
 */
 var longestPalindrome = function(s) {
    let length=s.length;
    if(length<2){
        return s;
    }
    let start=0;
    let maxlength=1;
    function expand(left ,right){
        while(left>=0 && right<length){
            if(s[left]!=s[right]){
                break;
            }
            left--;
            right++;
        }
            left++;
            right--;
        if(maxlength<right-left+1){
            maxlength=right-left+1;
            start=left;
        }
    }
    for(let i=0;i<length;i++){
        expand(i-1,i+1);
        expand(i,i+1);
    }
    return s.substr(start,maxlength);
};
let s='a'
console.log(longestPalindrome(s));